package com.qqt.csr.route.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.google.common.collect.Lists;
import com.qqt.csr.common.utils.JsonUtil;
import lombok.*;
import lombok.experimental.Accessors;
import net.bytebuddy.agent.builder.AgentBuilder;
import org.apache.commons.lang3.StringUtils;
import org.springframework.data.mongodb.core.mapping.Field;
import org.springframework.data.mongodb.core.mapping.FieldType;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * 客服路由业务规则
 */
@Getter
@Setter
@Accessors(chain = true)
@Builder
@AllArgsConstructor
@NoArgsConstructor
@TableName(value = "csr_route_biz_rule")
public class RouteBizRule implements Serializable {
    private static final long serialVersionUID = 1L;
    /**
     * 主键
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    /**
     * 是否熟客优先：0 否；1 是
     */
    @TableField(value = "acquaintance_first")
    private Integer acquaintanceFirst;

    /**
     * 客多少天内熟客优先
     */
    @TableField(value = "acquaintance_first_limit")
    private Integer acquaintanceFirstLimit;

    /**
     * 服务时间id
     */
    @TableField(value = "biz_time_id")
    private Integer bizTimeId;

    /**
     * 创建时间
     */
    @TableField(value = "create_time", fill = FieldFill.INSERT)
    @Field(targetType = FieldType.STRING)
    private Date createTime;

    /**
     * 是否移除：0 否；1 是
     */
    @TableField(value = "delete_flag")
    @TableLogic(value = "0", delval = "1")
    private Integer deleteFlag;

    /**
     * 分发规则：0 随机分配；1 轮询分配；2 会话量少优先分配；3 会话时长低优先分配
     */
    @TableField(value = "distribute_type")
    private Integer distributeType;

    /**
     * 业务名称
     */
    @TableField(value = "`name`")
    private String name;

    /**
     * 非服务时间拦截话术
     */
    @TableField(value = "rest_time_in_tip")
    private String restTimeInTip;

    /**
     * 路由id
     */
    @TableField(value = "rule_id")
    private Integer ruleId;

    /**
     * 技能组id集合
     */
    @TableField(value = "skill_set_ids")
    private String skillSetIds;

    /**
     * 更新时间
     */
    @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
    private Date updateTime;

    @JsonIgnore
    public List<Long> getSkillSetIdList() {
        return JsonUtil.toList(skillSetIds, Long.class);
    }
}